<?php

namespace app\index\model;

use  think\Db;

class SellModel
{
    static public function getList($param, $titles = null, $function = null){
        $db = Db::table('purchase_sell');
        !empty($param['code'])&&$db->where('code', 'in',explodeStr($param['code']));
        !empty($param['supplier_company_id'])&&$db->where('supplier_company_id', $param['supplier_company_id']);
        !empty($param['purchase_company_id'])&&$db->where('purchase_company_id', $param['purchase_company_id']);
        if (!empty($param['ctime'])) {
            $date = explode(' - ', $param['ctime']);
            count($date) == 2 &&
            $db->where('ctime', '>=', $date[0]) &&
            $db->where('ctime', '<=', $date[1]);
        }
        $db->order('id','desc');
        return \app\common\service\ToolService::downOrReturn($db, $param, $titles, $function);
    }
    static public function getSKuNum($ids){
        return DB::table('purchase_sell_detail')
            ->where('sell_id','in',$ids)
            ->group('sell_id')
            ->column("count(sku) as sku_num","sell_id");
    }
}